<?php

namespace app\admin\controller;
use think\DB;
use think\Request;
class Index extends Common 
{
	public function index(){
		return $this->fetch();
	}


	private function uuid() {
		if (function_exists ( 'com_create_guid' )) {
			return com_create_guid ();
		} else {
			mt_srand ( (double) microtime () * 10000 ); //optional for php 4.2.0 and up.随便数播种，4.2.0以后不需要了。
			$charid = strtoupper ( md5 ( uniqid ( rand (), true ) ) ); //根据当前时间（微秒计）生成唯一id.
			$hyphen = chr ( 45 ); // "-"
			$uuid = '' . //chr(123)// "{"
			substr ( $charid, 0, 8 ) . $hyphen . substr ( $charid, 8, 4 ) . $hyphen . substr ( $charid, 12, 4 ) . $hyphen . substr ( $charid, 16, 4 ) . $hyphen . substr ( $charid, 20, 12 );
			//.chr(125);// "}"
			return $charid.rand(1000, 9999);
  		}
	}

	private function create_unique() {  
		$data = $_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR'] . time() . rand(1000, 9999);  
		return $data;
		// return sha1($data);  
		//return md5(time().$data);  
		//return $data;  
	} 

	private function create_guid(){ 
    $microTime = microtime(); 
    list($a_dec, $a_sec) = explode(" ", $microTime); 
    $dec_hex = dechex($a_dec* 1000000); 
    $sec_hex = dechex($a_sec); 
    $this->ensure_length($dec_hex, 5); 
    $this->ensure_length($sec_hex, 6); 
    $guid = ""; 
    $guid .= $dec_hex; 
    $guid .= $this->create_guid_section(3); 
    $guid .= '-'; 
    $guid .= $this->create_guid_section(4); 
    $guid .= '-'; 
    $guid .= $this->create_guid_section(4); 
    $guid .= '-'; 
    $guid .= $this->create_guid_section(4); 
    $guid .= '-'; 
    $guid .= $sec_hex; 
    $guid .= $this->create_guid_section(6); 
    return $guid; 
} 
private function ensure_length(&$string, $length)   
 
{   
    $strlen = strlen($string);   
   if($strlen < $length)   
   {   
        $string = str_pad($string,$length,"0");   
    }   
     else if($strlen > $length)   
   {   
         $string = substr($string, 0, $length);   
  }   
 
 }   
 private function create_guid_section($characters) 
{ 
$return = ""; 
for($i=0; $i<$characters; $i++) 
{ 
$return .= dechex(mt_rand(0,15)); 
} 
return $return; 
} 
}
